import { request } from '@/plugins/request'
// 获取公共文章列表
export const getArticle = params => {
    return request({
        method:'GET',
        url:'/api/articles',
        params
    })
}
// 获取用户关注的文章列表
export const getFeedArticle = params => {
    return request({
        method:'GET',
        url:'/api/articles/feed',
        params
    })
}
// 添加点赞

export const addFavorite = slug =>{
    return request({
        method:'POST',
        url:`/api/articles/${slug}/favorite`,
    })
}
// 去掉点赞
export const deleteFavorite = slug =>{
    return request({
        method:'DELETE',
        url:`/api/articles/${slug}/favorite`,
    })
}

// 获取文章详情

export const getArticleDetail = slug =>{
    return request({
        method:'GET',
        url:`/api/articles/${slug}`,
    })
}

// 创建文章

export const createArticle = data =>{
    return request({
        method:'POST',
        url:`/api/articles`,
        data
    })
}


// 评论
export const addComments = (slug,data) =>{
    return request({
        method:'POST',
        url:`/api/articles/${slug}/comments`,
        data
    })
}
// 编辑评论
export const editComments = data =>{
    return request({
        method:'POST',
        url:`/api/articles/${data.slug}/comments`,
        data
    })
}

// 删除评论
export const deleteComments = (slug,id) =>{
    return request({
        method:'DELETE',
        url:`/api/articles/${slug}/comments/${id}`
    })
}

// 获取评论列表
export const getComments = slug =>{
    return request({
        method:'GET',
        url:`/api/articles/${slug}/comments`,
    })
}